<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <script>
        //2、定义一个数组求数组中的最大值
        var str = [2,3,13,23,24,35,77,0,11,6];
        str.sort(function(num1,num2){
            if(num1>num2){
                return 1;
            }else{
                return -1;
            }
        })
        //str[str.length-1]
        var max = str[str.length-1];
        console.log("最大值为："+max);


        //用Math.max取最大值
        // console.log(Math.max(2,3,13,23,24,35,77,0,11,6));
    </script>
</body>
</html>